package com.doit.day04

object _01_算子 {
  def main(args: Array[String]): Unit = {
    val list: List[Int] = List(1, 2, 3, 4, 5)
    val res: List[Int] = list.slice(1, 3)//List(2, 3)
    println(res)
    val res1: List[Int] = list.slice(2, 3)//List(3)
    println(res1)
    val res2: List[Int] = list.slice(1, 4)//List(2, 3, 4)
    println(res2)
    val res3: List[Int] = list.slice(2, 3)//List(3)
    println(res3)


    val iterator: Iterator[List[Int]] = list.sliding(2,2)
    while (iterator.hasNext){
      /**
       * List(1, 2)
         List(2, 3)
         List(3, 4)
         List(4, 5)

          List(1, 2)
          List(3, 4)
          List(5)
       */
      println(iterator.next())
    }



  }
}
